﻿using dotnet2cache.Abstractions;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace dotnet2cache.Memory
{
    public static class DTMemoryExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="memoryCacheOptions">控制内存大小</param>
        /// <returns></returns>
        public static CacheProvider AddDTLevel1CacheProvider(this CacheProvider provider, MemoryCacheOptions memoryCacheOptions)
        {
            provider.Services.AddSingleton<ILevel1CacheProvider>(new Level1CacheProvider(memoryCacheOptions));

            return provider;
        }


        public static CacheProvider AddDTLevel1CacheProvider(this CacheProvider provider)
        {
            return AddDTLevel1CacheProvider(provider,new MemoryCacheOptions());
        }

        
    }
}
